package first;

/**
 * @Author ZiXinXIE
 * @Date 2023-11-16 21:47
 */
public class TestDemo {
    public static void main(String[] args) {
        MyString myString = new MyString();
        myString.setValue("Luke");
        System.out.println(myString.getValue());

        String connectionStr = "XIE";
        System.out.println("--------------------拼接字符串--------------------");
        // 拼接字符串
        try {
            myString.connectionString(connectionStr);
            myString.connectionString(null);
            System.out.println(myString.getValue());
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("--------------------查找子串--------------------");
        // 查找子串在当前字符串中的索引位置。
        try {
            System.out.println("dsd在当前字符串中的索引位置：" + myString.indexOf("dsd"));
            System.out.println("XIE在当前字符串中的索引位置：" + myString.indexOf("XIE"));
            System.out.println("LukeXIEE在当前字符串中的索引位置：" + myString.indexOf("LukeXIEE"));
            System.out.println("8f在当前字符串中的索引位置：" + myString.indexOf(8f));
            System.out.println("null在当前字符串中的索引位置：" + myString.indexOf(null));
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("--------------------反转字符串--------------------");
        // 反转字符串
        System.out.println(myString.reverse());

        System.out.println("--------------------提取子串--------------------");
        // 提取子串
        try {
            System.out.println("myString.substring(1,3) = " + myString.substring(1, 3));
            System.out.println(myString.substring(0, 3));
            System.out.println(myString.substring(0, 4));
            System.out.println(myString.substring(-1, 3));
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("--------------------字符串对比--------------------");
        // 字符串对比
        System.out.println(myString.equal(null));
        System.out.println(myString.equal("ffsf"));
        System.out.println(myString.equal("null"));
        System.out.println(myString.equal("LukeXIE"));
        System.out.println(myString.equal(myString.getValue()));
    }
}
